You can write to a file in Node.js using the fs.writeFile() method. Here's an example:
fs.writeFile()